﻿using HModel;
using System;
using System.Windows.Forms;

namespace HMaker.Dialogs
{
    /// <summary>
    /// 资源信息编辑器窗体
    /// </summary>
    public partial class ResEditor : Form
    {
        /// <summary>
        /// 内部存储需要进行编辑的资源对象
        /// </summary>
        private ResEntity _Res;

        /// <summary>
        /// 设置或读取一个需要进行编辑的编辑器的信息
        /// </summary>
        public ResEntity Res
        {
            get => _Res; set
            {

                _Res = value;
                _Binding.DataSource = _Res;
            }
        }

        /// <summary>
        /// 用于绑定资源类型
        /// </summary>
        private readonly BindingSource _Binding = new BindingSource();


        /// <summary>
        /// 初始化一个资源信息编辑器
        /// </summary>
        public ResEditor()
        {
            InitializeComponent();

            TB_ResType.DataBindings.Add(new Binding("Text", _Binding, "Type"));
            TB_ResName.DataBindings.Add(new Binding("Text", _Binding, "Name"));
        }

        #region 事件响应函数


        private void Bn_Commit_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }
        #endregion


    }
}
